package chapter19.homework1;

public class TCLTv implements Tv {
    private Object[] objects = {"湖南卫视","北京卫视","上海卫视","湖北卫视","黑龙江卫视"};

    @Override
    public TVIterator createIterator() {
        return new TCLIterator();
    }

    class TCLIterator implements TVIterator {
        private int currentIndex = 0;

        @Override
        public void setChannel(int i) {
            currentIndex = i;
        }

        @Override
        public void next() {
            if (currentIndex < objects.length){
                currentIndex++;
            }
        }

        @Override
        public void previous() {
            if (currentIndex > 0){
                currentIndex--;
            }
        }

        @Override
        public boolean isLast() {
            return currentIndex == objects.length;
        }

        @Override
        public Object currentChannel() {
            return objects[currentIndex];
        }

        @Override
        public boolean isFirst() {
            return currentIndex == 0;
        }
    }
}
